﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MySql.Data.MySqlClient;

namespace ZHDJ.Data.Models.Org
{
    /// <summary>
    /// 组织基础信息配置
    /// </summary>
    public class PartyOrgBranchSetting:EntityBase
    {
        
        public string BranchID { get; set; }

        /// <summary>
        /// 设置类型
        /// </summary>
        public string SettingType { get; set; }

        /// <summary>
        /// 设置值
        /// </summary>
        public string SettingValue { get; set; }


        #region 数据操作

        /// <summary>
        /// 获取组织配置值
        /// </summary>
        /// <param name="branchID">组织ID</param>
        /// <param name="settingType">配置类型</param>
        /// <returns></returns>
        public static string GetSettingValue(string branchID, string settingType)
        {
            List<MySqlParameter> parameters = new List<MySqlParameter>()
            {
                new MySqlParameter()
                {
                    DbType = DbType.String,
                    ParameterName = "branchID",
                    Value = branchID
                },
                new MySqlParameter()
                {
                    DbType = DbType.String,
                    ParameterName = "SettingType",
                    Value = settingType
                }
            };
            string sql = string.Format(@" select SettingValue from tblPartyOrgBranchSetting where branchID=?branchID and  SettingType=?SettingType ");
            object obj = MySqlHelper.ExecuteScalar(sql, parameters.ToArray());
            if (obj != null) return obj.ToString();
            else return "";
        }

        #endregion
    }
}
